import pyautogui
import time
import cv2
import numpy as np 

# image = cv2.imread('./python/one2.png') # 根据路径读取一张图片
# cv2.imshow("BGR", image) # 显示图片

# # time.sleep(3)
x, y =pyautogui.position()
# # 获取鱼饵的坐标
# print("鱼饵的坐标", end = ':') # 1802 437
print(x,y)

# # 获取图片
# m = pyautogui.screenshot(region=(1365, 205, 489, 345))
# # 保存图片
# m.save('./python/a.png')
# # 获取图片
# m = pyautogui.screenshot(region=(1365, 205, 489, 345))
# # 保存图片
# m.save('./python/b.png')
# m.getpixel((100, 200))
# print(m)

img=cv2.imread('./python/a.png')
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
lower_green = np.array([24, 30, 32])
upper_green = np.array([180, 255, 255])
mask = cv2.inRange(hsv, lower_green, upper_green)
## mask of green (36,0,0) ~ (70, 255,255)
# mask1 = cv2.inRange(hsv, (36, 0, 0), (70, 255,255))

## mask of yellow (15,0,0) ~ (36, 255, 255)
# mask2 = cv2.inRange(hsv, (15,0,0), (36, 255, 255))

## final mask and masked
# mask = cv2.bitwise_or(mask1, mask2)
cv2.imshow('Input', img)
cv2.imshow('hsv', hsv)
cv2.imshow('mask', mask)

res = cv2.bitwise_and(img, img, mask=mask)
# cv2.imshow('Input', image)
cv2.imshow('Result', res)



if cv2.waitKey(0):
    cv2.destroyAllWindows()
# pyautogui.moveTo(696,410)
# pyautogui.click()

